package com.ltkj.ticket.controller;

import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicVenues;
import com.ltkj.ticket.service.ITicVenuesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 场馆门票Controller
 * 
 * @author ruoyi
 * @date 2023-08-30
 */
@Api(tags = "场馆门票")
@RestController
@RequestMapping("/venues")
public class TicVenuesController extends BaseController
{
    @Autowired
    private ITicVenuesService ticVenuesService;

    /**
     * 查询场馆门票列表
     */
    @ApiOperation("查询场馆门票列表")
    @RequiresPermissions("ticket:venues:list")
    @GetMapping("/list")
    public TableDataInfo list(TicVenues ticVenues)
    {
        startPage();
        List<TicVenues> list = ticVenuesService.selectTicVenuesList(ticVenues);
        return getDataTable(list);
    }
    @ApiOperation("查询场馆门票下拉")
    @RequiresPermissions("ticket:venues:list")
    @GetMapping("/listSelect")
    public AjaxResult listSelect(TicVenues ticVenues)
    {
        List<TicVenues> list = ticVenuesService.selectTicVenuesList(ticVenues);
        return success(list);
    }
    /**
     * 导出场馆门票列表
     */
    @ApiOperation("导出场馆门票列表")
    @RequiresPermissions("ticket:venues:export")
    @Log(title = "场馆门票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicVenues ticVenues)
    {
        List<TicVenues> list = ticVenuesService.selectTicVenuesList(ticVenues);
        ExcelUtil<TicVenues> util = new ExcelUtil<TicVenues>(TicVenues.class);
        util.exportExcel(response, list, "场馆门票数据");
    }

    /**
     * 获取场馆门票详细信息
     */
    @ApiOperation("获取场馆门票详细信息")
    @RequiresPermissions("ticket:venues:query")
    @GetMapping(value = "/{venuesId}")
    public AjaxResult getInfo(@PathVariable("venuesId") Long venuesId)
    {
        return success(ticVenuesService.selectTicVenuesByVenuesId(venuesId));
    }

    /**
     * 新增场馆门票
     */
    @ApiOperation("新增场馆门票")
    @RequiresPermissions("ticket:venues:add")
    @Log(title = "场馆门票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicVenues ticVenues)
    {
        return toAjax(ticVenuesService.insertTicVenues(ticVenues));
    }

    /**
     * 修改场馆门票
     */
    @ApiOperation("修改场馆门票")
    @RequiresPermissions("ticket:venues:edit")
    @Log(title = "场馆门票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicVenues ticVenues)
    {
        return toAjax(ticVenuesService.updateTicVenues(ticVenues));
    }

    /**
     * 删除场馆门票
     */
    @ApiOperation("删除场馆门票")
    @RequiresPermissions("ticket:venues:remove")
    @Log(title = "场馆门票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{venuesIds}")
    public AjaxResult remove(@PathVariable Long[] venuesIds)
    {
        return toAjax(ticVenuesService.deleteTicVenuesByVenuesIds(venuesIds));
    }

    /**
     * 下架景区门票基础
     */
    @ApiOperation("景区门票下架")
    @RequiresPermissions("ticket:venues:offshelf")
    @Log(title = "景区门票下架", businessType = BusinessType.OFFSHELF)
    @GetMapping("/offshelf/{venuesId}")
    public AjaxResult offshelf(@PathVariable("venuesId") Long venuesId)
    {
        return toAjax(ticVenuesService.offshelf(venuesId));
    }

    /**
     * 下架景区门票基础
     */
    @ApiOperation("景区门票上架")
    @RequiresPermissions("ticket:venues:onshelf")
    @Log(title = "景区门票上架", businessType = BusinessType.ONSHELF)
    @GetMapping("/onshelf/{venuesId}")
    public AjaxResult onshelf(@PathVariable("venuesId") Long venuesId)
    {
        return toAjax(ticVenuesService.onshelf(venuesId));
    }
}
